package com.softline.documentsmall.service.impl;

import com.google.common.collect.Maps;
import com.softline.documentsmall.dao.IndexLibraryNumMapper;
import com.softline.documentsmall.entity.IndexLibraryNum;
import com.softline.documentsmall.service.IndexLibraryNumService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author zhongweicheng
 * @date 2020/9/9 9:54
 */
@Service
@Slf4j
public class IndexLibraryNumServiceImp implements IndexLibraryNumService {

    @Autowired
    IndexLibraryNumMapper mapper;

    @Override
    public Map findAll() {
       List<IndexLibraryNum> lists = mapper.findAll();
       Map map = Maps.newHashMap();
       if(lists != null && lists.size() != 0){
           lists.stream().forEach(r->{
               map.put(r.getName(),r.getNum());
           });
       }
       return map;
    }
}
